package cnpm02.j2ee.group3.model;

import javax.persistence.AttributeOverride;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.validator.NotNull;

@Entity
@Table(name = "INTERMEDIATE_CITY", uniqueConstraints = @UniqueConstraint(columnNames = {
                "FlightLineId", "CityId"}))
@AttributeOverride(name = "id", column = @Column(name = "IntermediateCityId"))
public class IntermediateCity extends AbstractEntity {
	private static final long serialVersionUID = 1L;

	@NotNull
	@ManyToOne(cascade = { CascadeType.MERGE, CascadeType.PERSIST })
	@JoinColumn(name = "FlightLineId", nullable = false)
	private FlightLine flightLine;

	@NotNull
	@ManyToOne(cascade = { CascadeType.MERGE, CascadeType.PERSIST })
	@JoinColumn(name = "CityId", nullable = false)
	private City city;

	@NotNull
	@Column(name = "StopDuration")
	private int stopDuration;
	
	public void setFlightLine(FlightLine flightLine) {
		this.flightLine = flightLine;
	}
	
	public FlightLine getFlightLine() {
		return flightLine;
	}

	public void setCity(City city) {
		this.city = city;
	}

	public City getCity() {
		return city;
	}

	public void setDuration(int duration) {
		this.stopDuration = duration;
	}

	public int getDuration() {
		return stopDuration;
	}
	
}
